/*
 * Copyright (c) 2010 Zauber S.A.  -- All rights reserved
 */
package ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.bitwise;

import java.util.List;

import org.apache.commons.lang.Validate;

import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.Expresion;
import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.impl.AbstractExpresion;

/**
 * Operador booleano and
 * 
 * @author Juan F. Codagnone
 * @since Mar 27, 2010
 */
public class Or extends AbstractBinaryExpression {
    /** caracter representativo */
    static final char CHAR = '|';

    /** constructor */
    public Or(final Expresion e1, final Expresion e2) {
        Validate.notNull(e1);
        Validate.notNull(e2);

        childs.add(e1);
        childs.add(e2);
    }
    
    /** @see Expresion#eval(boolean[]) */
    public final boolean eval(final boolean... vargs) {
        boolean ret = false;
        for(int i = 0; i < vargs.length; i++) {
            ret |= vargs[i];
        }
        return ret;
    }    
    
    /** @see Expresion#getCharacter() */
    public final char getCharacter() {
        return CHAR;
    }
    
    /** @see AbstractExpresion#clone(java.util.List) */
    @Override
    protected final Expresion clone(final List<Expresion> clones) {
        return new Or(clones.get(0), clones.get(1));
    }
}
